package org.wyn.mongodb.bean;

import java.util.ArrayList;
import java.util.List;

import org.bson.types.ObjectId;
import org.wyn.common.Table;

import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
import com.google.code.morphia.annotations.Indexed;
import com.google.code.morphia.utils.IndexDirection;

/**
 * 日志实体类
 * @author wyn
 *
 */
@Entity(value = Table.CollectionName.BLOG, noClassnameStored = true)
public class Blog {
	@Id
	@Indexed(value = IndexDirection.ASC)
	private ObjectId blogId;
	@Indexed(value = IndexDirection.ASC)
	private String title;//日志标题
	private String content;//日志正文 目前只支持文字
	@Indexed(value = IndexDirection.ASC)
	private String authorUserName;//日志作者userName
	private String authorRealName;//日志作者realName
	private ObjectId authorPortrait = new ObjectId();//日志作者头像
	private long createTime;//日志创建时间
	private long lastModifyTime;//最后修改时间
	private int viewNum;//日志被阅读次数
	private List<Comment> comments = new ArrayList<Comment>();//评论
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getAuthorUserName() {
		return authorUserName;
	}
	public void setAuthorUserName(String authorUserName) {
		this.authorUserName = authorUserName;
	}
	public String getAuthorRealName() {
		return authorRealName;
	}
	public void setAuthorRealName(String authorRealName) {
		this.authorRealName = authorRealName;
	}
	public long getCreateTime() {
		return createTime;
	}
	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}
	public long getLastModifyTime() {
		return lastModifyTime;
	}
	public void setLastModifyTime(long lastModifyTime) {
		this.lastModifyTime = lastModifyTime;
	}
	public int getViewNum() {
		return viewNum;
	}
	public void setViewNum(int viewNum) {
		this.viewNum = viewNum;
	}

	public List<Comment> getComments() {
		return comments;
	}
	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}
	public ObjectId getBlogId() {
		return blogId;
	}
	public void setBlogId(ObjectId blogId) {
		this.blogId = blogId;
	}
	public ObjectId getAuthorPortrait() {
		return authorPortrait;
	}
	public void setAuthorPortrait(ObjectId authorPortrait) {
		this.authorPortrait = authorPortrait;
	}
	/*
	 * 造测试假数据
	 */
	public static Blog createTestBlog(){
		Blog b = new Blog();
		b.title = "大地的裂变";
		b.content = "大地的裂变  正式片头动画.... 死亡之翼来了";
		b.authorUserName = "wwmm.cs@gmail.com";
		b.authorRealName = "吴明";
		b.createTime = System.currentTimeMillis() - 100000;
		b.lastModifyTime = System.currentTimeMillis();
		b.viewNum = 12;
		b.comments = new ArrayList<Comment>();
		b.comments.add(Comment.buildComment("ruirui", "睿睿", System.currentTimeMillis()));
		b.comments.add(Comment.buildComment("shizi", "狮子", System.currentTimeMillis()));
		b.comments.add(Comment.buildComment("shiya", "诗雅", System.currentTimeMillis()));
		b.comments.add(Comment.buildComment("liuqi", "刘琦", System.currentTimeMillis()));
		b.comments.add(Comment.buildComment("yuanlin", "袁琳", System.currentTimeMillis()));
		return b;
	}
}
